 /*
  * The contents of this file are subject to the Mozilla Public License
  * Version 1.1 (the "License");  you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  * http//www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  * the specific language governing rights and limitations under the License.
  *
  * The Original Code is ART Ontology API.
  *
  * The Initial Developer of the Original Code is University of Roma Tor Vergata.
  * Portions created by University of Roma Tor Vergata are Copyright (C) 2007.
  * All Rights Reserved.
  *
  * ART Ontology API was developed by the Artificial Intelligence Research Group
  * (ai-nlp.info.uniroma2.it) at the University of Roma Tor Vergata
  * Current information about the ART Ontology API can be obtained at 
  * http//ai-nlp.info.uniroma2.it/software/...
  *
  */

  /*
   * Contributor(s): Armando Stellato stellato@info.uniroma2.it
  */
package it.uniroma2.art.owlart.langsearch.index;

import java.util.Collection;

import com.google.common.base.Predicate;

import it.uniroma2.art.owlart.model.ARTLiteral;

/**
 * this predicate is used to pass literals which have their iso language included in a set of accepted languages
 * A instance of this predicate is initialized with a collection of the languages used as filters  
 * 
 * @author Armando Stellato
 *
 */
public class DesiredLanguageLabelsPredicate implements Predicate<ARTLiteral> {

	public Collection<String> filterLanguages;

	public DesiredLanguageLabelsPredicate(Collection<String> filterLanguages) {
		this.filterLanguages = filterLanguages;
	}

	public boolean apply(ARTLiteral res) {
		/*
		if (res.getLabel().contains("TROTA"))
			System.out.println("desired label" + (res.getLanguage().equalsIgnoreCase(filterLanguage)?" ":" not") + " found: ");
		else
			System.out.println("analyzing label: " + res.getLabel());
		*/
		
		String lang = res.getLanguage();
		if ( (lang != null) && ( filterLanguages.contains(lang) ) )
			return true;
		else
			return false;
	}

}
